const express = require('express');
const router = express.Router();

// 导入解析 formdata 格式表单数据的包
const multer = require('multer');
// 导入处理路径的核心模块
const path = require('path');

// 创建multer实例
const uploads = multer({ dest: path.join(__dirname, '../uploads') });

// 导入验证数据的中间件
const expressJoi = require('@escook/express-joi');
// 导入文章的验证模块
const { add_article_schema } = require('../schema/article');

// 导入需要的处理函数模块
const article_handler = require('../router_handler/article');
// 发布新文章的路由
router.post('/add', uploads.single('cover_img'), expressJoi(add_article_schema), article_handler.addArticle);

module.exports = router;
